<template>
    <div class="researchAlbumWarp">
        <div class="albumBox" v-if="!isAlbumDetale">
            <div class="albumtitle">
                <label>教研组相册</label>
                <el-button type="text" @click="uploadAblum=true">上传照片</el-button>
                <el-button type="primary" size="mini" class="addBtn" @click="newAlbum=true">增加</el-button>
            </div>

            <el-row :gutter="20" class="elRow">
                <el-col :span="4" v-for="index in 6" :key="index">
                    <div class="grid-content">
                        <div class="cover">
                            <label class="number">1{{index}}</label>
                            <el-image :src="cover" @click="isAlbumDetale = true"></el-image>
                            <div class="editDelete">
                                <el-button type="text" @click="newAlbum=true">编辑</el-button>
                                <el-divider direction="vertical"></el-divider>
                                <el-button type="text" style="color: #F56C6C;">删除</el-button>
                            </div>
                        </div>
                        <div class="albumName">
                            <label>美少女战士</label>
                        </div>
                    </div>
                </el-col>
            </el-row>
        </div>

        <div class="albumDetail" v-if="isAlbumDetale">
            <div class="head">
                <div class="cover">
                    <el-image :src="cover"></el-image>
                </div>
                <div class="btns">
                    <h3>枯木会逢春</h3>
                    <el-button type="primary" size="mini" @click="uploadAblum=true">上传照片</el-button>
                </div>
                <el-button type="primary" size="mini" class="saveBtn" @click="isAlbumDetale = false">保存
                </el-button>
            </div>
            <el-row :gutter="20" class="elRow">
                <el-col :span="4" v-for="index in 6" :key="index">
                    <div class="grid-content">
                        <div class="cover">
                            <el-image :src="cover"></el-image>
                            <div class="editDelete">
                                <el-button type="text">设为封面</el-button>
                                <el-divider direction="vertical"></el-divider>
                                <el-button type="text" style="color: #F56C6C;">删除</el-button>
                            </div>
                        </div>
                    </div>
                </el-col>
            </el-row>
        </div>

        <el-dialog
                title="上传照片"
                :visible.sync="uploadAblum"
                width="40%"
                center>

            <div class="uploadAblumDialog">
                <div class="uploadLocation">
                    <label>上传到:</label>
                    <el-select v-model="UploadLocation" placeholder="请选择" size="mini">
                        <el-option label="人生低谷" value="0"></el-option>
                        <el-option label="无fuck说" value="1"></el-option>
                    </el-select>
                </div>
                <div class="selectAblum">
                    <el-upload
                            action="https://jsonplaceholder.typicode.com/posts/"
                            list-type="picture-card"
                            :multiple="true"
                            :on-preview="handlePictureCardPreview"
                            :on-remove="handleRemove">
                        <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible">
                        <img width="100%" :src="dialogImageUrl" alt="">
                    </el-dialog>
                </div>
            </div>

            <span slot="footer" class="dialog-footer">
                        <el-button size="mini" @click="uploadAblum = false" >上传照片</el-button>
                        <el-button type="primary" size="mini" @click="uploadAblum = false">完 成</el-button>
                    </span>
        </el-dialog>

        <el-dialog title="相册新增" :visible.sync="newAlbum" width="25%">
            <el-form :model="newAlbumForm">
                <el-form-item label="相册名称" label-width="72px">
                    <el-input v-model="newAlbumForm.ablumName" size="mini" placeholder="请输入相册名称" ></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="newAlbum = false" >取 消</el-button>
                <el-button type="primary" size="mini" @click="newAlbum = false">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "researchAlbum",
        data(){
            return{
                cover: require('../../assets/img/headportrait01.jpg'),
                isAlbumDetale: false,
                uploadAblum:false, // 上传照片弹窗
                newAlbum:false, // 相册新增弹窗
                newAlbumForm:{
                    ablumName:''
                },
                UploadLocation:'', // 图片上传位置
                dialogImageUrl: '',
                dialogVisible: false,
            }
        },
        methods:{

            // 文件列表移除文件时的钩子
            handleRemove(file, fileList) {
                // console.log(file, fileList);
            },

            // 点击文件列表中已上传的文件时的钩子
            handlePictureCardPreview(file) {
                this.dialogImageUrl = file.url;
                this.dialogVisible = true;
            },
        }
    }
</script>

<style lang="scss" scoped>
    .researchAlbumWarp{
        width: 100%;

        .albumBox {

            .albumtitle {
                text-align: left;
                border-bottom: 1px solid #ccc;
                margin-bottom: 10px;
                position: relative;

                & > label {
                    color: #303133;
                    margin-right: 15px;
                    font-size: 16px;
                }

                .addBtn {
                    position: absolute;
                    top: 5px;
                    right: 0px;
                }
            }
        }

        .elRow {
            margin-bottom: 15px;

            .grid-content {
                width: 100%;
                border: 1px solid #EBEEF5;

                .cover {
                    width: 100%;
                    height: 170px;
                    position: relative;
                    overflow: hidden;
                    cursor: pointer;

                    .number {
                        position: absolute;
                        top: 0;
                        left: 0;
                        display: block;
                        width: 25px;
                        height: 25px;
                        border-radius: 50%;
                        background-color: #409eff;
                        text-align: center;
                        line-height: 25px;
                        font-size: 12px;
                        color: #fff;
                        z-index: 9;

                    }

                    .editDelete {
                        width: 100%;
                        box-sizing: border-box;
                        background-color: rgba(255, 255, 255, .8);
                        position: absolute;
                        bottom: -40px;
                        left: 0;
                        transition: bottom .3s;
                    }
                }

                .cover:hover .editDelete {
                    bottom: 0;
                }

                .albumName {
                    width: 100%;
                    height: 30px;
                    font-size: 14px;
                    color: #303133;
                    text-align: center;
                    line-height: 30px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }
            }
        }

        .albumDetail {
            .head {
                width: 100%;
                height: 130px;
                border-bottom: 1px solid #EBEEF5;
                position: relative;
                margin-bottom: 10px;

                .cover {
                    width: 120px;
                    height: 120px;
                    overflow: hidden;
                    float: left;
                }

                .btns {
                    float: left;
                    margin-left: 10px;
                }

                .saveBtn {
                    position: absolute;
                    right: 0;
                    top: 55px;
                }

            }
        }

        .uploadAblumDialog{
            .uploadLocation{
                label{
                    margin-right: 10px;
                }
            }

            .selectAblum{
                margin-top: 20px;
            }
        }

    }
</style>
